package com.example.environment.configuration;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class CrossConfiguration implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                // 配置哪些来源有权限跨域
                .allowedOrigins("*")//前端地址
                // 配置运行跨域访问的请求方法
                .allowedMethods("GET", "POST", "DELETE", "PUT");
    }
}